import com.huaweicloud.sdk.iot.device.client.requests.CommandRsp;
import com.huaweicloud.sdk.iot.device.service.AbstractService;
import com.huaweicloud.sdk.iot.device.service.DeviceCommand;
import com.huaweicloud.sdk.iot.device.service.Property;

import java.util.Map;
import java.util.Random;

public class Nczt extends AbstractService {


    public float getSwwd() {
        swwd = new Random().nextFloat()*10.1f;
        return swwd;
    }

    //按照设备模型定义属性，注意属性的name和类型需要和模型一致，writeable表示属性知否可写，name指定属性名
    @Property(name = "swwd", writeable = false)                  //可读true
            float swwd = 0.1f;


    public int getSwsd() {
        swsd = new Random().nextInt(100);
        return swsd;
    }

    @Property(name = "swsd", writeable = false)    //不可读false
        int swsd = 1;


    public float getSsfs() {
        ssfs = new Random().nextFloat()*1.1f;
        return ssfs;
    }

    @Property(name = "ssfs",writeable = false)
        float ssfs= 0.1f;


    public float getSsyl() {
        ssyl = new Random().nextFloat()*1.1f;
        return ssyl;
    }

    @Property(name = "ssyl",writeable = false)
        float ssyl=0.1f;


    public float getQy() {
        qy = new Random().nextFloat()*1000.1f;
        return qy;
    }

    @Property(name = "qy",writeable = false)
        float qy=0.1f;


    public float getGzqd() {
        gzqd = new Random().nextFloat()*1000.1f;
        return gzqd;
    }

    @Property(name = "gzqd",writeable = false)
        float gzqd=0.1f;


    //定义命令，注意接口入参和返回值类型是固定的不能修改，否则会出现运行时错误
//    @DeviceCommand(name = "ringAlarm")
//    public CommandRsp alarm(Map<String, Object> paras) {
//
//
//        int duration = (int) paras.get("duration");
//        System.out.println("ringAlarm  duration = " + duration);
//        //将log换成System.out.println
//        CommandRsp commandRsp=new CommandRsp(0);
//        commandRsp.setResponseName("COMMAND_RESPONSE");
//        //定制
//        return commandRsp;
//    }

    //setter和getter接口的命名应该符合java bean规范，sdk会自动调用这些接口


//    public void setSmokeAlarm(int smokeAlarm) {
//
//        this.smokeAlarm = smokeAlarm;
//        if (smokeAlarm == 0){
//            System.out.println("alarm is cleared by app");
//        }
//    }


}
